package com.controller;

import com.pojo.Inventory;
import com.service.impl.InventoryServiceImpl;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * (Inventory)表控制层
 *
 * @author makejava
 * @version 1.0
 * @since 2022-04-08 12:33:27
 */
@RestController
@RequestMapping("/inventory")
public class InventoryController {
    /**
     * 服务对象
     */
    @Resource
    private InventoryServiceImpl inventoryServiceImpl;


    //新增药品批次
    @RequestMapping(value = "/insert")
    public Map<String, Object> insert(@RequestBody Inventory inventory) {
        return this.inventoryServiceImpl.insert(inventory);
    }

    // 通过主键更新单条数据
    @RequestMapping(value = "/updateById")
    public Map<String, Object> updateById(@RequestBody Inventory inventory) {
        return this.inventoryServiceImpl.updateById(inventory);
    }

    /**
     * 通过ID查询批次数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @RequestMapping(value = "/selectById")
    public Map<String, Object> selectById(String id) {
        return this.inventoryServiceImpl.selectById(id);
    }

    /**
     * 查询所有数据
     *
     * @return 返回所有数据
     */
    @RequestMapping(value = "/selectAll")
    public Map<String, Object> selectAll() {
        return this.inventoryServiceImpl.selectAll();
    }

    /**
     * 通过主键删除单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @RequestMapping(value = "/deleteById")
    public Map<String, Object> deleteById(@RequestParam("id") String id) {
        return this.inventoryServiceImpl.deleteById(id);
    }
}